define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	var service = require('../js/service');
	
	var Model = function(){
		this.callParent();
	};

	Model.prototype.logoutBtnClick = function(event){
		service.logout(function(){
			justep.Shell.closePage();
		});
	};

	Model.prototype.addNoteBtnClick = function(event){
		service.addNote(function(res){
			justep.Shell.showPage('edit', {
				data: {
					id: res.id,
					title: '新事件',
					detail: '事件详情',
					created: '',
					modified: ''
			}});
		});
	};

	Model.prototype.notesDataCustomRefresh = function(event){
		service.listNote(function(res){
			event.source.loadData(res, false);
		});
	};
	
	Model.prototype.int2Time = function(intTime) {
		var t = new Date();
		t.setTime(intTime);
		return t;
	};

	Model.prototype.noteListItemClick = function(event){
		var id = event.bindingContext.$object.val('id');
		
		service.getNote(id, function(res){
			justep.Shell.showPage('detail', {
				data: res
			});
		});
		
		
	};

	return Model;
});